package com.yeyaomai.dksns.flowis.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.yeyaomai.dksns.flowis.dao.OperatorDao;
import com.yeyaomai.dksns.flowis.domain.Operator;
import com.yeyaomai.dksns.flowis.page.PageImplResult;
import com.yeyaomai.dksns.flowis.page.PageRequestOrder;
import com.yeyaomai.dksns.flowis.page.SplitConstant;
import com.yeyaomai.dksns.flowis.service.OperatorService;

@Service
public class OperatorServiceImpl implements OperatorService {

	@Resource
	private OperatorDao operatorDao;
	
	@Override
	public Operator getOperatorById(long id) {
		
		return operatorDao.getOperatorById(id);
	}

	@Override
	public List<Operator> getOperatorByDay(Map<String, Object> map) {
		
		return operatorDao.getOperatorByDay(map);
	}

	@Override
	public Page<Operator> getDataPage(Map<String, Object> map,
			Integer currentpage) {
		long operatorCount = operatorDao.getOperatorCount(map);
		PageRequestOrder request = new PageRequestOrder(currentpage,
				SplitConstant.PAGE_SIZE);
		List<Operator> operatorList = new ArrayList<Operator>();
		map.put("startNumber", request.start());
		map.put("endNumber", request.end());
		operatorList = operatorDao.getOperatorByDay(map);
		Page<Operator> result = new PageImplResult<Operator>(operatorList,
				request, operatorCount);
		return result;
	}

	@Override
	public Operator getOperatorByTime(String fromDate, String toDate) {
		
		return operatorDao.getOperatorByTime(fromDate, toDate);
	}

	@Override
	public List<Operator> getOperatorByName(Map<String, Object> map) {
		return operatorDao.getOperatorByName(map);
	}

}
